package hzjbbis.commons.maintenance.action;

import hzjbbis.commons.maintenance.dao.SingleTableDao;
import hzjbbis.commons.maintenance.handler.TempletStandard;
import hzjbbis.commons.maintenance.handler.request.SaveRequestHandler;
import hzjbbis.commons.pk.PrimaryKeyValue;
import hzjbbis.framework.tree.TreeNode;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * @version 	1.0
 * @author		lix
 */
public class InsertNodeAction extends Action {

	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {

		SaveRequestHandler requestHandler =
			new SaveRequestHandler(request, TempletStandard.INSERT_NODE_KEY_HANDLER);

		PrimaryKeyValue pkValue = (PrimaryKeyValue)SingleTableDao.executeHandler(requestHandler);

		//		request.setAttribute("result",obj);

		TreeNode treeNode = requestHandler.getTreeNode(pkValue);

		request.setAttribute("xml", treeNode.toString());

		return mapping.findForward("submitSuccess");
	}

}
